<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue"></script>
</head>
<body>
    <div id="app">
        <component :is="view"></component>
        <button @click="hanleChange">切换</button>
    </div>
    <script>
        Vue.component('mycomponent1',{
            template:`
               <div>mycomponent1</div>
            `
        })
        Vue.component('mycomponent2',{
            template:`
               <div>mycomponent2</div>
            `
        })
        //根组件
        var app = new Vue({
            el:'#app',
            data:{
                view:'mycomponent1'
            },
            methods:{
                hanleChange(){
                    this.view = 'mycomponent2'
                }
            }
        })
    </script>
</body>
</html>